<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/pc', function(){
    return view('pc');
});

Route::group([
    'namespace' =>  'App'
], function(){
    Route::any('/wechat', 'WechatController@serve');

    Route::any('/register', 'LoginController@register')->name('user.register');
    Route::any('/login', 'LoginController@login')->name('user.login');
    Route::get('/logout', 'LogoutController')->name('user.logout');

    Route::get('/', 'LuoController@index');
    Route::get('/luo/my', 'LuoController@my_luo');
    Route::get('/luo/{id}', 'LuoController@luo');
    Route::get('/luo/{id}/event', 'LuoController@event');
    Route::get('/luo/{id}/users', 'LuoController@users');
    Route::any('/luo/{id}/add_post', 'LuoController@add_post');
    Route::get('/pages/{page}', 'LuoController@page');

    Route::get('/posts/{id}', 'LuoController@post');
    Route::get('/posts/{id}/comment', 'LuoController@get_comments');
    Route::post('/posts/{id}/comment', 'LuoController@comment');

    Route::get('/users/{id}', 'UserController@user');
});

Route::group([
    'namespace' =>  'Admin',
    'prefix'    =>  'admin',
], function(){
    Route::any('/login',  'LoginController@login')->name('admin.login');
    Route::get('/logout', 'LogoutController')->name('admin.logout');
    // admin dashboard
    Route::get('/', 'DashboardController');

    // admin users
    Route::get('/users', 'AdminUserController@users');
    Route::any('/users/create', 'AdminUserController@create_user');
    Route::any('/users/create_luo_admin', 'AdminUserController@create_luo_admin');
    Route::any('/users/{id}/edit', 'AdminUserController@edit_user');
    Route::post('/users/{id}/delete', 'AdminUserController@delete_user');

    // user ants
    Route::get('/ants', 'AntUserController@users');
    Route::get('/ants/q/{query}', 'AntUserController@query');
    Route::get('/ants/luo/{name}', 'AntUserController@luo_users');
    Route::any('/ants/{id}/review', 'AntUserController@review');
    Route::post('/ants/{id}/delete', 'AntUserController@delete');

    // admin luo
    Route::get('/luo', 'LuoController@index');
    Route::any('/luo/create', 'LuoController@add');
    Route::any('/luo/{id}/edit', 'LuoController@edit');
    Route::post('/luo/{id}/delete', 'LuoController@delete');

    // admin profile
    Route::any('/profile/edit', 'ProfileController@edit');
    Route::any('/profile/password', 'ProfileController@password');

    // admin posts
    Route::get('/posts/{review?}', 'PostController@posts');
    Route::post('/posts/{id}/review', 'PostController@review');
    Route::post('/posts/{id}/delete', 'PostController@delete');

    // admin comments
    Route::get('/comments', 'CommentController@comments');
    Route::post('/comments/{id}/delete', 'CommentController@delete');
});
